<template>
  <div>
    <div v-if="loading" class="set-loading">
      <img src="@/assets/image/loading.gif" alt />
    </div>
    <div class="container" v-if="hotelData.length !== 0">
      <div>
        <!-- 面包屑 -->
        <div class="breadcrumb">
          <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: `/hotel?cityName=${hotelData[0].city.name}` }">酒店</el-breadcrumb-item>
            <el-breadcrumb-item>
              <a :href="`/hotel?cityName=${hotelData[0].city.name}`">{{ hotelData[0].real_city }}酒店</a>
            </el-breadcrumb-item>
            <el-breadcrumb-item>{{ hotelData[0].name }}</el-breadcrumb-item>
          </el-breadcrumb>
        </div>
        <!-- 标题 -->
        <div class="name-info">
          <div class="hotel-title">
            <h4>
              {{ hotelData[0].name }}
              <span title="星级" v-if="hotelData[0].hotellevel">
                <i class="iconfont iconhuangguan"></i>
                <i class="iconfont iconhuangguan"></i>
                <i class="iconfont iconhuangguan"></i>
                <i class="iconfont iconhuangguan"></i>
                <i class="iconfont iconhuangguan"></i>
              </span>
            </h4>
          </div>
          <div>
            <span>{{ hotelData[0].alias }}</span>
          </div>
          <div>
            <i class="iconfont iconlocation"></i>
            {{ hotelData[0].address }}
          </div>
        </div>
        <!-- 酒店图片 -->
        <div class="pic-info">
          <HotelPic />
        </div>
        <!-- 酒店价格 -->
        <div class="price-info">
          <el-table :data="hotelData[0].products" style="width: 100%" @row-click="jumpHotelPage">
            <el-table-column prop="name" label="价格来源" width="420"></el-table-column>
            <el-table-column prop="bestType" label="低价房型" width="420"></el-table-column>
            <el-table-column prop="price" label="最低价格/每晚">
              <template slot-scope="scope">
                <span class="height-light larger">￥{{ scope.row.price }}</span> 起
                <span>
                  <i class="el-icon-arrow-right height-light"></i>
                </span>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <!-- 地图 -->
        <HotelMap
          v-if="hotelData.length !==0"
          :hotelData="hotelData"
          :location="hotelData[0].location"
        />
        <!-- 酒店详细信息 -->
        <div class="hotel-info">
          <div class="el-row">
            <div class="base_info">
              <div class="hd" style="padding-right:100px;">基本信息</div>
              <div style="padding-right:68px;" class="bd">入住时间: 14:00之后</div>
              <div style="padding-right:68px;" class="bd">离店时间: 12:00之前</div>
              <div
                style="padding-right:68px;"
                class="bd"
              >{{ hotelData[0].creation_time }} / {{ hotelData[0].renovat_time }}</div>
              <div style="padding-right:68px;" class="bd">酒店规模: {{ hotelData[0].roomCount }}间客房</div>
            </div>
          </div>
          <div class="el-row main_facilities">
            <div style="padding-right:100px;">主要设施</div>
            <div
              class="hu"
              v-for="(item, index) in hotelData[0].hotelassets"
              :key="index"
              style="margin-right:10px"
            >{{ item.name }}</div>
          </div>
          <div class="el-row Parking service">
            <div style="padding-right:100px;">停车服务</div>
            <div v-if="hotelData[0].parking">{{ hotelData[0].parking }}</div>
            <div v-else>-</div>
          </div>
          <div class="el-row Brand information">
            <div style="padding-right:100px;">品牌信息</div>
            <div v-if="hotelData[0].hotelbrand">{{ hotelData[0].hotelbrand.name }}</div>
          </div>
        </div>
        <!-- 用户评论 -->
        <div class="comment">
          <h4>0条真实评论</h4>
          <div class="flex">
            <div class="detail_comment">
              <p>总评数：{{ hotelData[0].all_remarks }}</p>
              <p>好评数：{{ hotelData[0].good_remarks }}</p>
              <p>差评数：{{ hotelData[0].bad_remarks }}</p>
            </div>
            <div class="starts">
              <el-rate
                v-model="hotelData[0].stars"
                disabled
                show-score
                text-color="#ff9900"
                :score-template="`${hotelData[0].stars}分`"
              ></el-rate>
              <div class="stamp">推荐</div>
            </div>
            <div class="scores">
              <div class="text">
                <span class="title">环境</span>
                <span class="value">{{ hotelData[0].scores.environment }}</span>
              </div>
            </div>
            <div class="scores">
              <div class="text">
                <span class="title">产品</span>
                <span class="value">{{ hotelData[0].scores.product }}</span>
              </div>
            </div>
            <div class="scores">
              <div class="text">
                <span class="title">服务</span>
                <span class="value">{{ hotelData[0].scores.service }}</span>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import HotelPic from "@/components/hotel/detailTopInfo/hotelPic";
import HotelMap from "@/components/hotel/detailMapInfo/HotelMap";
export default {
  components: {
    HotelPic,
    HotelMap
  },
  data() {
    return {
      // 酒店信息的所有数据
      loading: true,
      hotelData: []
    };
  },
  mounted() {
    // 调用函数获取酒店信息的数据
    this.loadPage();
  },
  methods: {
    //获取该酒店的详细数据
    loadPage() {
      this.$axios({
        url: "/hotels?id=" + this.$route.params.id
      }).then(res => {
        console.log(res.data);
        this.loading = false;
        this.hotelData = res.data.data;
      });
    },
    // 点击酒店价格表跳转页面
    jumpHotelPage() {
      window.open("https://hotels.ctrip.com/hotel/694679.html");
    }
  }
};
</script>

<style lang="less" scoped>
.container {
  width: 1000px;
  margin: 0 auto;
  .breadcrumb {
    padding: 20px 0;
  }
  .name-info {
    margin-bottom: 20px;
    color: #666;
    font-size: 14px;
    h4 {
      color: #333;
      font-weight: 400;
      font-size: x-large;
    }
    .iconhuangguan {
      margin-right: -8px;
      color: orange;
    }
  }
}
.pic-info {
  margin: 40px 0;
}
.price-info {
  margin: 40px 0;
  cursor: pointer;
  .height-light {
    font-size: 20px;
    color: orange;
  }
}

.hotel-info {
  margin-bottom: 100px;
  margin: 40px 0;
  box-sizing: border-box;
  .el-row {
    border-bottom: 1px solid #e4e4e4;
    padding: 20px 10px;
    font-size: 14px;
    display: flex;
    .base_info {
      display: flex;
      .bd,
      .bd {
        padding-right: 10px;
      }
      .bd {
        color: #666;
      }
      // flex: 1;
    }
  }
  .main_facilities {
    box-sizing: border-box;
    .hu {
      color: #666;
      padding: 4px 10px;
      border: 1px solid #eee;
      background-color: #eee;
      border-radius: 4px;
    }
  }
}
// 酒店评论
.comment {
  .el-rate__icon {
    font-size: 18px;
    margin-right: 6px;
    transition: 0.3s;
  }
  .flex {
    display: flex;
    padding: 20px 0;
    .detail_comment {
      color: #666;
      margin-right: 70px;
    }
    .starts {
      position: relative;
      margin-top: 10px;
      margin-right: 35px;
      /deep/ .el-rate__icon {
        font-size: 22px;
        margin-right: 3px;
      }
      .stamp {
        position: absolute;
        left: 30px;
        top: -12px;
        width: 70px;
        height: 70px;
        line-height: 70px;
        text-align: center;
        border-radius: 50%;
        color: orange;
        border: 1px solid orange;
        font-size: 25px;
        opacity: 0.25;
        transform: rotate(-30deg);
      }
    }
    .scores {
      width: 65px;
      height: 65px;
      border: 2px solid #ff9900;
      border-left-color: #fff;
      color: orange;
      border-radius: 50%;
      font-size: 16px;
      transform: rotate(45deg);
      margin: 0px 20px;
      position: relative;
      .text {
        transform: rotate(-45deg);
        .title {
          position: absolute;
          top: 3px;
          left: -7px;
        }
        .value {
          position: absolute;
          top: 25px;
          left: -1px;
        }
      }
    }
  }
}
.set-loading {
  width: 441px;
  margin: 100px auto 900px;
}
</style>
